const http = require('http');
// 返回图片
const fs=require('fs')

// 返回数据 
const httpServer=
http.createServer(function(req,res){
    // res.writeHead(200,{'content-type':'text/html;charset=utf-8'});
    // res.write("<ul><li>数据</li></ul>");
    // res.end();

    // 返回图片
    res.writeHead(200,{'content-type':'image/jpeg'});
    let str=fs.createReadStream('D:/Node.js_File/ch02/Picturebrowsing/img/img1.jpg');
    let str2=fs.createReadStream('D:/Node.js_File/ch02/Picturebrowsing/img/img2.jpg');
    let str3=fs.createReadStream('D:/Node.js_File/ch02/Picturebrowsing/img/img3.jpg');
    let str4=fs.createReadStream('D:/Node.js_File/ch02/Picturebrowsing/img/img4.jpg');
    // 流式读取，错误处理
    // str.on('error.')
    str.pipe(res);
    str2.pipe(res);
    str3.pipe(res);
    str4.pipe(res);

});
httpServer.listen(8888,function(){
    console.log("已监听；");
})